#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXN 500005
#define MAXC 1000005

typedef struct {
    int x, y;
} Point;

int n, m;
Point points[MAXN];
int x_coords[MAXN], y_coords[MAXN];
int x_map[MAXC], y_map[MAXC];
int x_cnt, y_cnt;

int cmp(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

void compress_coords(int* coords, int* map, int* cnt) {
    qsort(coords, *cnt, sizeof(int), cmp);
    *cnt = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0 || coords[i] != coords[i - 1]) {
            map[coords[i]] = ++(*cnt);
        }
    }
}

int min(int a, int b) {
    return a < b ? a : b;
}

int max(int a, int b) {
    return a > b ? a : b;
}

int abs(int x) {
    return x < 0 ? -x : x;
}

int dist(int x1, int y1, int x2, int y2) {
    return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &points[i].x, &points[i].y);
        x_coords[i] = points[i].x;
        y_coords[i] = points[i].y;
    }

    x_cnt = y_cnt = n;

    compress_coords(x_coords, x_map, &x_cnt);
    compress_coords(y_coords, y_map, &y_cnt);

    int t, x, y;
    for (int i = 0; i < m; i++) {
        scanf("%d %d %d", &t, &x, &y);
        if (t == 1) {
            // Add a new point
            points[n].x = x;
            points[n].y = y;
            n++;
        }
        else if (t == 2) {
            // Query the nearest point
            int min_dist = MAXC * 2;
            for (int j = 0; j < n; j++) {
                min_dist = min(min_dist, dist(x, y, points[j].x, points[j].y));
            }
            printf("%d\n", min_dist);
        }
    }

    return 0;
}